include(BenchmarkMacros)

set(FAST_MATH_BENCHMARK FALSE CACHE BOOL "Use floating point math shortcuts. Might not be IEEE compliant!")
if(FAST_MATH_BENCHMARK)
   if(CMAKE_COMPILER_IS_GNUCXX)
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffast-math")
   elseif(CMAKE_CXX_COMPILER MATCHES "/(icpc|icc)$")
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fp-model fast=2")
   elseif(MSVC)
   endif(CMAKE_COMPILER_IS_GNUCXX)
endif(FAST_MATH_BENCHMARK)

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
   set(REALTIME_BENCHMARKS FALSE CACHE BOOL "Use SCHED_FIFO priority to give benchmarks highest priority, achieving less jitter in the results.")
   if(REALTIME_BENCHMARKS)
      add_executable(benchmark benchmark.cpp)
      add_definitions(-DSCHED_FIFO_BENCHMARKS)
   endif(REALTIME_BENCHMARKS)
endif(CMAKE_SYSTEM_NAME STREQUAL "Linux")

vc_add_benchmark(arithmetics)
vc_add_benchmark(flops)
vc_add_benchmark(gather VC_NO_BSF_LOOPS VC_NO_GATHER_TRICKS VC_SLOWDOWN_GATHER)
vc_add_benchmark(mask)
vc_add_benchmark(compare VC_DISABLE_PTEST)
vc_add_benchmark(math)
vc_add_benchmark(memio)
vc_add_benchmark(dhryrock)
vc_add_benchmark(whetrock)

add_executable(sort_benchmark sort.cpp)
target_link_libraries(sort_benchmark Vc ${LIBS})
add_target_property(sort_benchmark OUTPUT_NAME sort)
add_custom_target("run_sort_benchmark" sort_benchmark DEPENDS sort_benchmark COMMENT "Running sort")
add_target_property("run_sort_benchmark" EXCLUDE_FROM_DEFAULT_BUILD 1)
add_dependencies(benchmarks "run_sort_benchmark")

vc_generate_plots(arithmetics)
vc_generate_plots(flops)
vc_generate_plots(gather VC_NO_BSF_LOOPS VC_NO_GATHER_TRICKS)
vc_generate_plots(mask)
vc_generate_plots(compare VC_DISABLE_PTEST)
vc_generate_plots(math)
vc_generate_plots(memio)

add_executable(constants constants.cpp)
target_link_libraries(constants Vc ${LIBS})
